package com.zheng.rpc.registry.zk;

import com.zheng.rpc.registry.ServiceRegistry;
import com.zheng.rpc.utils.CuratorUtil;
import org.apache.curator.framework.CuratorFramework;

import java.net.InetSocketAddress;

public class ZkRegistry implements ServiceRegistry {
    @Override
    public void registryService(String serviceName, InetSocketAddress address) {
        String servicePath = CuratorUtil.ZK_REGISTER_ROOT_PATH + "/" + serviceName + address.toString();
        CuratorFramework zkClient = CuratorUtil.getZkClient();
        CuratorUtil.createPersistentNode(zkClient, servicePath);
    }
}
